package com.hiray.demos.rv_related

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.hiray.demos.ItemAdapter
import com.hiray.demos.R
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration
import kotlinx.android.synthetic.main.activity_layout_manager_entry.*

class LayoutManagerEntryActivity : AppCompatActivity(), ItemAdapter.OnItemClickListener {


    val items = arrayListOf(
            "LinearLayoutManager",
            "DividerForGridLayout"
    )

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_layout_manager_entry)
        recyclerview.adapter = ItemAdapter(items, this)
        recyclerview.addItemDecoration(HorizontalDividerItemDecoration.Builder(this@LayoutManagerEntryActivity)
                .colorResId(R.color.divider_light)
                .size(5)
                .build())
    }

    override fun onItemClick(position: Int) {
        when (position) {
            0 -> startActivity(Intent(this, LinearLayoutManagerActivity::class.java))
            1 -> startActivity(Intent(this, GridLayoutDividerActivity::class.java))
        }
    }
}
